/*
* @Author       : HONGKELI lihongkje@outlook.com
* @Date         : 2024-04-24 16:57:14
 * @LastEditors  : HONGKELI lihongkje@outlook.com
 * @LastEditTime : 2024-04-25 10:46:54
* @FilePath     : /EngMath/tests/Test_Plane.h
* @Description  : 
*/

#ifndef Test_Plane_H
#define Test_Plane_H

#include <iostream> 
#include <vector>
#include <EngMath/Models/Vector3d.h>
#include <EngMath/Models/Plane.h>

namespace tests{

// useful  
// distance of point to plane
void Test_compute_point_to_plane_distance(){

    std:: cout << "一个平面，其上一点为 {0, 0, 0}，法线向量为 {0, 0, 1}"  << std::endl;
    EM::Plane plane({0, 0, 0}, {0,0,1});
    double double_distance = 0;
    plane.compute_point_to_plane_distance({1,1,1},double_distance);
    std::cout << "空间中定点{1,1,1} 到此平面的距离为(1): " << double_distance << std::endl;

    std:: cout << "一个平面，其上一点为 {0.5, 0.5, 0.5}，法线向量为 {0, 0, 1}"  << std::endl;
    EM::Plane plane_1({0.5, 0.5, 0.5}, {0, 0, 1});
    double double_distance_1 = 0;
    plane_1.compute_point_to_plane_distance({1.7, 1.7, 1.7},double_distance_1);
    std::cout << "空间中定点{1,1,1} 到此平面的距离为(1.2): " << double_distance_1 << std::endl;
}

// useful  
// flatness of a point list to plane
void Test_compute_flatness_average_distance(){

    std:: cout << "平面plane_1，其上一点为 {0.5, 0.5, 0.5}，法线向量为 {0, 0, 1}"  << std::endl;
    EM::Plane plane_1({0.5, 0.5, 0.5}, {0, 0, 1});
    double double_distance_1 = 0;
    plane_1.compute_point_to_plane_distance({1.7, 1.7, 1.7},double_distance_1);
    std::cout << "空间中定点{1,1,1} 到此平面plane_1的距离为(1.2): " << double_distance_1 << std::endl;
    
    std::vector<EM::Vector3d> list_Points(100,{1.7, 1.7, 1.7});
    double double_flatness = 0;
    plane_1.compute_flatness_average_distance(list_Points,double_flatness);
    std::cout << "对于100 个 空间点 {1.7, 1.7, 1.7} 其对于平面 plane_1的平面度应为（1.2），计算结果为：" << double_flatness << std::endl;
}


// usefull 
// flatness of Standard deviatio
void Test_compute_flatness_standard_deviation_distance(){
    std:: cout << "平面plane_1，其上一点为 {0.5, 0.5, 0.5}，法线向量为 {0, 0, 1}"  << std::endl;
    EM::Plane plane_1({0.5, 0.5, 0.5}, {0, 0, 1});

    // 加入离散点集
    std::vector<EM::Vector3d> points = {
        {0.5, 0.5, 0.8},    
        {0.5, 0.5, 0.5}, 
        {0.5, 0.5, 0.2},  
        {0.5, 0.5, 1.0}     
    };
    
    double flatness_standard_deviation;
    plane_1.compute_flatness_standard_deviation_distance(points, flatness_standard_deviation);

    // 离散度校验
    std::cout << "The standard deviation of distances from points to the plane is " 
        << flatness_standard_deviation << std::endl;
}

void Test_compute_degree(){


    
}












}













#endif